package cn.gson.crm.model.pojos;

import javax.persistence.*;
import java.util.List;
import java.util.Objects;

@Entity
@Table(name = "DEPT_FUNCTIONS", schema = "CRM", catalog = "")
public class DeptFunctions {
    private long dpId;
    private Long fstId;
    private List<Functions> functions;
    @ManyToMany
    @JoinTable(name = "DEPT_FUNCTIONS",
            joinColumns = {
                    @JoinColumn(name="DP_ID")
            },
            inverseJoinColumns = {
                    @JoinColumn(name = "FST_ID")
            })
    public List<Functions> getFunctions() {
        return functions;
    }

    public void setFunctions(List<Functions> functions) {
        this.functions = functions;
    }

    @Id
    @Column(name = "DP_ID", nullable = false, precision = 0)
    public long getDpId() {
        return dpId;
    }

    public void setDpId(long dpId) {
        this.dpId = dpId;
    }

    @Column(name = "FST_ID", nullable = true, precision = 0)
    public Long getFstId() {
        return fstId;
    }

    public void setFstId(Long fstId) {
        this.fstId = fstId;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        DeptFunctions that = (DeptFunctions) o;
        return dpId == that.dpId &&
                Objects.equals(fstId, that.fstId);
    }

    @Override
    public int hashCode() {
        return Objects.hash(dpId, fstId);
    }
}
